package cn.bdqn.service;

import org.hibernate.HibernateException;
import org.hibernate.Transaction;

import cn.bdqn.dao.EmpDao;
import cn.bdqn.entity.Emp;

public class EmpService {
	private EmpDao empDao = new EmpDao();
	public void addNewEmp(Emp emp){
		Transaction transaction = null;
		try{
			transaction = empDao.currentSession().beginTransaction();
			empDao.save(emp);
			transaction.commit();
		}catch(HibernateException e){
			e.printStackTrace();
			if(transaction!=null){
				transaction.rollback();
			}
		}
	}
}
